import React, { useEffect, useState } from "react";
// 就诊卡页面
import { patientList } from "./sevice/HomeList";
import { useNavigate } from "react-router-dom";
// import style form "../"
import style from "./css/Home.module.css";
import { Toast, NavBar } from "react-vant";
import { Cell } from "react-vant";
import { Button } from "react-vant";
import { Arrow } from "@react-vant/icons";
import { Plus, LocationO } from '@react-vant/icons'
export default function Patient() {
  let [list, setList] = useState([]); //为数组
  let navigate = useNavigate();

  useEffect(() => {
    (async () => {
      let { data } = await patientList();
      console.log(data, "逻辑错误");
      
      setList(data.rows);

    })();
  }, []);
  useEffect(() => {
    console.log(list, "就诊人信息");
  }, [list]);
  let btn = () => {
    console.log(999999);//跳转到其他的页面。
    navigate("/house/addpatient")
    console.log(99);


  }
  return (
    <div className={style.body}>
      <NavBar
        title="就诊人卡片"
        leftText="返回"
        onClickLeft={() => window.history.back(-1)}
        className={style.navBar}
      />

      <div className={style.sy}>
        {/* <Cell title='单元格' isLink />
        <Cell >
      <div></div>
    </Cell> */}

        {list?.map((item) => {
          return (
            <div key={item.id} className={style.cell}>
              <Cell title={item.name} isLink border={false}></Cell>
              <Cell border={false}>
                <div className={style.border}>
                  <div className={style.padding}>身份证号：{item.cardId}</div>
                  <div className={style.padding}>手机号：{item.tel}</div>
                </div>
              </Cell>
            </div>
          );
        })}
        <Cell onClick={() => {
          btn()
        }}><div className={style.add}><Plus  />添加就诊人</div></Cell>
      </div>
    </div>
  );
}
